package cn.jdy.plugins.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.jdy.common.ctrl.BaseCtrl;
import cn.jdy.framework.log.BaseLog;
import cn.jdy.platform.entity.News;
import cn.jdy.platform.service.ConfService;
import cn.jdy.platform.service.NewsService;

/**
 * @title 安全服务
 * @author zhagt
 * @date 2015-05-01
 */
@Controller
@RequestMapping("/safecenter")
public class SafeCenterCtrl extends BaseCtrl {
	@Autowired
	private NewsService newsService;
	@Autowired
	private ConfService confService;

	/**
	 * 查询安全服务首页
	 * @param news
	 * @return
	 */
	@RequestMapping("")
	public ModelAndView query(News news) {
		ModelAndView mv = new ModelAndView("/safecenter/sfaeList.jsp");
		try {
			//设置分页信息
			if(news.getiDisplayLength() == 0) news.setiDisplayLength(10);                //默认长度5
			if(news.getPageNo()<=0) news.setPageNo(1);                                  //默认页数1
			news.setiDisplayStart((news.getPageNo() - 1) * news.getiDisplayLength());  //显示起始索引

			news.setStatus("1");
			
			mv.addObject("dataList", newsService.query(news));
			mv.addObject("pageNo", news.getPageNo());
			mv.addObject("size", news.getiDisplayLength());

			mv.addObject("total", newsService.count(news));
			mv.addObject("news", news);
		} catch(Exception e) {
			BaseLog.e(this.getClass(), "查询文章异常", e);
		}
		return mv;
	}
	
	/**
	 * 申请解封
	 * @param news
	 * @return
	 */
	@RequestMapping("open")
	public ModelAndView open() {
	  ModelAndView mv = new ModelAndView("/safecenter/open.jsp");
	  
	  return mv;
	}
	
	/**
	 * 站长平台
	 * @param news
	 * @return
	 */
	@RequestMapping("zhanzhang")
	public ModelAndView zhanzhang() {
	  ModelAndView mv = new ModelAndView("/safecenter/zhanzhang.jsp");
	  
	  return mv;
	}
	 
}